/**
 * 
 */
package blackBoxTest;

import static org.junit.Assert.*;


import java.util.ArrayList;

import org.junit.Test;

import reports.builders.TestBuilder;
import reports.directors.ProductStatisticsReport;
import reports.directors.ProductStatsGenerator;
import testHelper.FileList;
import testHelper.Scraper;
import tools.Importer;

/**
 * @author nathan
 *
 */

// Description[0]
//Barcode	Size[1]
//3-Month Supply[2]
//Supply: Cur/Avg[3]
//Supply: Min/Max[4]
//Supply: Used/Added[5]
//Shelf Life[6]
//Used Age: Avg/Max[7]
//Cur Age: Avg/Max[8]
/**
 * Note: all test are ran against Rodam's demo program
 * Because of this the results are only accurate on the day it is ran
 * Other wise the averages are off
 */
public class SupplyAndSizeTest {

	/**
	 * @throws java.lang.Exception
	 */



/**
 * this test different values for size supply and shelf life
 * to see if they affect the report
 */
	@Test
	public void test() {

		
		ProductStatsGenerator.setEndDate(30, 3, 2012);
		
		int y=2;

		System.out.println("*****Testing file "+FileList.getInstance().getXMLFile(y));
		Scraper scraper = new Scraper(FileList.getInstance().getHTMLFile(y));
		TestBuilder builder = new TestBuilder();
		String[] arg= new String[1];
		arg[0]= FileList.getInstance().getXMLFile(y);
		//import file
		Importer.main(arg);

		ProductStatisticsReport report = new ProductStatisticsReport(3);
		report.build(builder);
		// test to make sure loads worked
		assertTrue(builder!=null);
		assertTrue(scraper!=null);
		int rows=builder.getRowCount();
		for(int x=0; x<rows;x++)
		{
			ArrayList<String> row =(ArrayList<String>) builder.getRow(x);
			ArrayList<String> answerRow=scraper.getColumn(x);
			for(int i=0;i<10;i++)
			{
				//System.out.println(FileList.getInstance().removeWhiteSpace(row.get(i))+" equals? "+FileList.getInstance().removeWhiteSpace(answerRow.get(i)));
				assertTrue("the oracle has " +row.get(i)+" our code has "+answerRow.get(i),FileList.getInstance().removeWhiteSpace(row.get(i)).equalsIgnoreCase(FileList.getInstance().removeWhiteSpace(answerRow.get(i))));
			}
		}
	}
	
	



}
